Skip to content

Latest commit

 

History

History
68 lines (43 loc) · 2.62 KB

hello-world.mdx

File metadata and controls

68 lines (43 loc) · 2.62 KB
id title subtitle breadcrumb
ai-vecs-python-client
Creating and managing collections
Connecting to your database with Colab.
AI Quickstarts

This guide will walk you through a basic "Hello World" example using Colab and Supabase Vecs. You'll learn how to:

  1. Launch a Postgres database that uses pgvector to store embeddings
  2. Launch a notebook that connects to your database
  3. Create a vector collection
  4. Add data to the collection
  5. Query the collection

Launching a notebook

Launch our vector_hello_world notebook in Colab:

<a className="w-64" href="https://colab.research.google.com/github/supabase/supabase/blob/master/examples/ai/vector_hello_world.ipynb"

At the top of the notebook, you'll see a button Copy to Drive. Click this button to copy the notebook to your Google Drive.

Connecting to your database

Inside the Notebook, find the cell which specifies the DB_CONNECTION. It will contain some code like this:

import vecs

DB_CONNECTION = "postgresql://<user>:<password>@<host>:<port>/<db_name>"

# create vector store client
vx = vecs.create_client(DB_CONNECTION)

Replace the DB_CONNECTION with your own connection string for your database. You can find the Postgres connection string in the Database Settings of your Supabase project.

SQLAlchemy requires the connection string to start with postgresql:// (instead of postgres://). Don't forget to rename this after copying the string from the dashboard.

You must use the "connection pooling" string (domain ending in *.pooler.supabase.com) with Google Colab since Colab does not support IPv6.

Stepping through the notebook

Now all that's left is to step through the notebook. You can do this by clicking the "execute" button (ctrl+enter) at the top left of each code cell. The notebook guides you through the process of creating a collection, adding data to it, and querying it.

You can view the inserted items in the Table Editor, by selecting the vecs schema from the schema dropdown.

Colab documents

Next steps

You can now start building your own applications with Vecs. Check our examples for ideas.